package com.whk0710.util;

import java.io.InputStream;
import java.net.HttpURLConnection;
import java.net.URL;

public class ImageService {
	
	/**
	 * GetImage
	 * @return
	 * @param path
	 * @throws Exception
	 * */
	public static byte[] getImage(String path) throws Exception {
		URL url = new URL(path);
		HttpURLConnection conn = (HttpURLConnection) url.openConnection();
		conn.setConnectTimeout(5000);
		conn.setRequestMethod("GET");
		if (conn.getResponseCode() == 200) {
			InputStream inStream = conn.getInputStream();
			byte[] data = StreamTool.read(inStream);
			return data;
		}
		return null;
	}
}